package acwing;

import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class ac802 {
    static final int N = 100010;
    static int[] a = new int[N];
    static int[] s = new int[N];
    static int n;
    static int m;
    static List<Point> add = new ArrayList<>();
    static List<Integer> all = new ArrayList<>();
    static List<Point> query = new ArrayList<>();
    static Map<Integer, Integer> mp = new HashMap<>();
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
    public static void main(String[] args) throws IOException {
        String[] str = in.readLine().split(" ");
        n = Integer.parseInt(str[0]);
        m = Integer.parseInt(str[1]);
        
        for(int i = 0; i < n; i ++ ){
            int x, c;
            str = in.readLine().split(" ");
            x = Integer.parseInt(str[0]);
            c = Integer.parseInt(str[1]);
            add.add(new Point(x, c));
            all.add(x);
        }
        
        for(int i = 0; i < m; i ++ ){
            int l, r;
            str = in.readLine().split(" ");
            l = Integer.parseInt(str[0]);
            r = Integer.parseInt(str[1]);
            query.add(new Point(l, r));
            all.add(l);
            all.add(r);
        }
        Collections.sort(all);
        unique(all);
        
        int cnt = 1;
        for (Integer i : all){
            mp.put(i, cnt ++ );
        }
        
        for (Point i : add){
            int first = (int) i.getX();
            int x = mp.get(first);
            a[x] += i.getY();
        }
        
        for (int i = 1; i <= all.size(); i ++ ){
            s[i] += s[i - 1] + a[i];
        }
        
        for (Point i : query){
            int l = mp.get((int)i.getX());
            int r = mp.get((int)i.getY());
            System.out.println(s[r] - s[l - 1]);
        }
        
    }
    
    static void unique(List<Integer> list) {
        HashSet<Integer> hashSet = new HashSet(list);
        list.clear();
        list.addAll(hashSet);
    }
}
